package org.lisa.crm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.lisa.crm.dao.CustomerLossDao;
import org.lisa.crm.model.CustomerLoss;
import org.lisa.crm.service.CustomerLossService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/2/3.
 */

@Service
public class CustomerLossServiceImpl implements CustomerLossService {

    @Autowired
    private CustomerLossDao customerLossDao;

    @Override
    public Map<String, Object> queryCustomerLossesByParams(CustomerLoss customerLoss) {

        List<CustomerLoss> list=customerLossDao.queryCustomerLossesByParams(customerLoss);

        PageHelper.startPage(customerLoss.getPage(),customerLoss.getRows());

        PageInfo<CustomerLoss> info=new PageInfo<>(list);

        Map<String,Object> map=new HashMap<>();

        map.put("total",info.getTotal());
        map.put("rows",info.getList());

        return map;
    }

    @Override
    public CustomerLoss queryCustomerLossById(int lossId) {

        return customerLossDao.queryCustomerLossById(lossId);

    }
}
